package matrix

func rotate(matrix [][]int)  {
	N := len(matrix)
	x, y := 0, 0
	x1, y1 := N-1, N-1

	for x < x1{
		rotateMatrix(x, y, x1, y1, matrix)
		x++
		y++
		x1--
		y1--
	}
}

func rotateMatrix(x, y, x1, y1 int, matrix [][]int){
	var tem int
	for i:=0; i<x1 - x; i++ {
		tem = matrix[x][y+i]
		matrix[x][y+i] = matrix[x1-i][y]
		matrix[x1-i][y] = matrix[x1][y1-i]
		matrix[x1][y1-i] = matrix[x+i][y1]
		matrix[x+i][y1] = tem
	}
}
